#ifndef __LOG_HPP__
#define __LOG_HPP__

#include <iostream>
#include <ctime>
#include <cstdio>
#include <cstring>

#define INF 0
#define DBG 1
#define ERR 2
#define DEFAULT_LEVEL INF

#define LOG(level,format,...) do{\
    if(level<DEFAULT_LEVEL) break;\
    time_t tm=time(nullptr);\
    struct tm* ltm=localtime(&tm);\
    char sltm[32];\
    bzero(sltm,sizeof(sltm));\
    strftime(sltm,sizeof(sltm)-1,"%H:%M:%S",ltm);\
    fprintf(stdout,"[%s %s:%d]" format "\n",sltm,__FILE__,__LINE__,##__VA_ARGS__);\
}while(0);

#define ILOG(format,...) LOG(INF,format,##__VA_ARGS__)
#define DLOG(format,...) LOG(DBG,format,##__VA_ARGS__)
#define ELOG(format,...) LOG(ERR,format,##__VA_ARGS__)

#endif